/**
 * 
 */
package org.o14x.alpha.ui.views.folder;

import java.io.File;
import java.util.Iterator;

import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.DragSourceListener;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.PartPane;
import org.eclipse.ui.internal.PartSite;
import org.eclipse.ui.internal.PartStack;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;
import org.eclipse.ui.part.ViewPart;
import org.o14x.alpha.domain.ExplorerTab;
import org.o14x.alpha.services.FileServices;
import org.o14x.alpha.ui.controller.UIController;
import org.o14x.alpha.ui.views.folder.columns.ColumnHelper;

/**
 * View showing the content of the current folder.
 * 
 * @author Olivier DANGREAUX
 */
@SuppressWarnings("restriction")
public class FolderView extends ViewPart {
	/**
	 * ID
	 */
	public static final String ID = FolderView.class.getName();

	/**
	 * The UIController.
	 */
	private UIController uiController;

	/**
	 * The TableViewer showing the content of the current folder.
	 */
	private TableViewer tableViewer;

	/**
	 * The table showing the content of the current folder.
	 */
	private Table table;

	/**
	 * The ExplorerTab associated with this view. 
	 */
	private ExplorerTab explorerTab;

	/**
	 * The FileTableLabelProvider.
	 */
	private FileTableLabelProvider fileTableLabelProvider;

	/**
	 * The tab item associated with this view
	 */
	private CTabItem tabItem;

	/**
	 * The sort listener.
	 */
	private Listener sortListener;

	/**
	 * Creates a new instance of FolderView.
	 */
	public FolderView() {
		setTitleImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
	}

	@Override
	public void createPartControl(Composite parent) {

		uiController.getDomain().getCurrentExplorerTab().setFolderView(this);
		explorerTab = uiController.getDomain().getCurrentExplorerTab();

		Composite composite = new Composite(parent, SWT.NO_FOCUS);

		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 1;
		composite.setLayout(gridLayout);

		GridData gridData1 = new GridData();
		gridData1.grabExcessHorizontalSpace = true;
		gridData1.horizontalAlignment = SWT.FILL;

		tableViewer = new TableViewer(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);

		// tableViewer.setColumnProperties(titles);
		tableViewer.setContentProvider(new FileTableContentProvider());
		tableViewer.setLabelProvider(fileTableLabelProvider);

		table = tableViewer.getTable();
		table.setLayoutData(new GridData(GridData.FILL_BOTH));
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		tableViewer.addDoubleClickListener(new IDoubleClickListener() {

			@Override
			public void doubleClick(DoubleClickEvent event) {
				StructuredSelection selection = (StructuredSelection) event.getSelection();
				File selectedFile = (File) selection.getFirstElement();
				if (selectedFile.isDirectory()) {
					// uiController.getDomain().getCurrentExplorerTab().setFolder(selectedFile);
					explorerTab.navigate(selectedFile);
					update();
					uiController.getUi().getFolderTreeView().update();
					uiController.getUi().getAddressBarContributionItem().update();
				} else {
					Program.launch(selectedFile.getPath());
				}
			}
		});

		// Listener for sorting
		sortListener = new Listener() {
			public void handleEvent(Event e) {
				// determine new sort column and direction
				TableColumn sortColumn = tableViewer.getTable().getSortColumn();
				TableColumn currentColumn = (TableColumn) e.widget;
				int dir = tableViewer.getTable().getSortDirection();
				if (sortColumn == currentColumn) {
					dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
				} else {
					tableViewer.getTable().setSortColumn(currentColumn);
					dir = SWT.UP;
				}

				tableViewer.getTable().setSortDirection(dir);
				Sorter sorter = new Sorter(ColumnHelper.getColumnHelper(currentColumn), dir);
				sorter.setUiController(uiController);
				tableViewer.setSorter(sorter);
			}
		};

		// columns creation
		initColumns();

		// item deselection when table is clicked outside any item
		table.addMouseListener(new MouseAdapter() {
			/* (non-Javadoc)
			 * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent)
			 */
			@Override
			public void mouseDown(MouseEvent e) {
				// the clicked TableItem
				TableItem clickedTableItem = table.getItem(new Point(e.x, e.y));

				// if no item is clicked, clear selection
				if (clickedTableItem == null) {
					table.deselectAll();
				}
			}
		});

		// context menu
		addContextMenu();

		// drag n drop support
		addDragSupport();
		addDropSupport();

		initTabFolder();
		initTabItem();

		update();
	}

	/**
	 * Inits or reinits columns of the table.
	 */
	public void initColumns() {
		for (TableColumn tableColumn : table.getColumns()) {
			tableColumn.dispose();
		}

		// columns creation
		uiController.getUi().getColumnHelperManager().getColumnHelperList();
		for (ColumnHelper columnHelper : uiController.getUi().getColumnHelperManager().getColumnHelperList()) {
			if (columnHelper.isEnabled()) {
				columnHelper.createTableColumn(table, sortListener);
			}
		}
	}

	@Override
	public void setFocus() {
		initTabItem();

		uiController.getDomain().setCurrentExplorerTab(explorerTab);
		File currentDirectory = explorerTab.getFolder();
		while (!currentDirectory.exists()) {
			currentDirectory = currentDirectory.getParentFile();
		}
		explorerTab.navigate(currentDirectory);

		update();
		uiController.getUi().getFolderTreeView().update();
	}

	/**
	 * Update this view according to the current folder.
	 */
	public void update() {
		File currentFolder = uiController.getDomain().getCurrentExplorerTab().getFolder();

		tableViewer.setInput(currentFolder);

		String title = currentFolder.getName();
		if (currentFolder.getParentFile() == null) {
			title = currentFolder.toString();
		}

		setPartName(title);
		setTitleToolTip(currentFolder.getPath());
	}

	@Override
	public void dispose() {
		super.dispose();
		uiController.getDomain().getExplorerTabManager().removeExplorerTab(explorerTab.getId());

		if (uiController.getDomain().getExplorerTabManager().countExplorerTabs() > 1) {
			explorerTab.getExplorerTreeViewer().getControl().dispose();
		} else if (!PlatformUI.getWorkbench().isClosing()) {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(FolderView.ID, uiController.getDomain().getCurrentExplorerTab().getId(), IWorkbenchPage.VIEW_ACTIVATE);
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		}
	}

	private void initTabFolder() {
		if (uiController.getUi().getFolderViewTabFolder() == null) {
			IWorkbenchPartSite site = this.getSite();
			PartPane currentEditorPartPane = ((PartSite) site).getPane();
			PartStack stack = currentEditorPartPane.getStack();
			if (stack != null) {
				Control control = stack.getControl();
				if (control instanceof CTabFolder) {
					CTabFolder tabFolder = (CTabFolder) control;

					uiController.getUi().setFolderViewTabFolder(tabFolder);
					addTabFolderDropSupport();
				}
			}
		}
	}

	private void initTabItem() {
		if (tabItem == null) {
			IWorkbenchPartSite site = this.getSite();
			PartPane currentEditorPartPane = ((PartSite) site).getPane();
			PartStack stack = currentEditorPartPane.getStack();
			if (stack != null) {
				Control control = stack.getControl();
				if (control instanceof CTabFolder) {
					CTabFolder tabFolder = (CTabFolder) control;
					tabItem = tabFolder.getSelection();
					if (tabItem == null && tabFolder.getItemCount() == 1) {
						tabItem = tabFolder.getItem(0);
					}

					if (tabItem != null) {
						tabItem.setData("org.o14x.alpha.ui.views.folder.FolderView", this);
					}
				}
			}
		}
	}

	/*************************************************************************************************
	 * DRAG N DROP
	 ************************************************************************************************/

	/**
	 * Adds file drag support.
	 */
	private void addDragSupport() {
		// defines file table as a drag source
		Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
		int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
		tableViewer.addDragSupport(operations, types, new DragSourceListener() {
			@Override
			public void dragStart(DragSourceEvent event) {
			}

			@SuppressWarnings("unchecked")
			@Override
			public void dragSetData(DragSourceEvent event) {
				IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
				String[] selectedPaths = new String[selection.size()];
				int i = 0;
				for (Iterator iterator = selection.iterator(); iterator.hasNext();) {
					File selectedFile = (File) iterator.next();
					selectedPaths[i] = selectedFile.getAbsolutePath();
					i++;
				}
				event.data = selectedPaths;
			}

			@Override
			public void dragFinished(DragSourceEvent event) {
			}
		});
	}

	/**
	 * Adds file drop support.
	 */
	private void addDropSupport() {
		Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
		int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;

		// defines files table as a drop target
		DropTarget target = new DropTarget(table, operations);
		target.setTransfer(types);
		target.addDropListener(new DropTargetListener() {
			@Override
			public void dropAccept(DropTargetEvent event) {

			}

			@Override
			public void drop(DropTargetEvent event) {
				// computes the target directory
				File targetDirectory = null;
				TableItem tableItem = (TableItem) event.item;
				if (tableItem != null) {
					File targetFile = (File) tableItem.getData();
					if (targetFile != null && targetFile.isDirectory()) {
						// drag over a directory => target directory is this directory
						targetDirectory = targetFile;
					}
				} else {
					// target directory is the current directory
					targetDirectory = uiController.getDomain().getCurrentExplorerTab().getFolder();
				}

				if (targetDirectory != null) {
					// paths of the files to be dropped
					String[] droppedPaths = (String[]) event.data;

					FileServices fileServices = uiController.getServices().getFileServices();

					// files to be dropped
					File[] droppedFiles = fileServices.toFiles(droppedPaths);

					// if there is files to be dropped
					if (droppedFiles.length > 0) {
						// move operation
						if (event.detail == DND.DROP_MOVE) {
							// if dropped files are not from the target directory
							if (!droppedFiles[0].getParentFile().equals(targetDirectory)) {
								// moves files
								fileServices.move(droppedFiles, targetDirectory, true, true);
								update();
							}
						}
						// copy operation
						else if (event.detail == DND.DROP_COPY) {
							// if dropped files are from the target directory
							if (droppedFiles[0].getParentFile().equals(targetDirectory)) {
								// modify the name of the files before copy
								fileServices.duplicate(droppedFiles, targetDirectory);
								update();
							} else {
								// copy files without modifying their names
								fileServices.copy(droppedFiles, targetDirectory, false, true);
								update();
							}
						}
					}
				}
			}

			@Override
			public void dragOver(DropTargetEvent event) {
				TableItem tableItem = (TableItem) event.item;
				int detail = event.detail;
				if (event.detail == DND.DROP_NONE) {
					detail = DND.DROP_DEFAULT;
				}

				// if drag over an item
				if (tableItem != null) {
					File targetFile = (File) tableItem.getData();

					// drop can be done only on a directory
					if (targetFile != null && targetFile.isDirectory()) {
						event.detail = detail;
					} else {
						event.detail = DND.DROP_NONE;
					}
				}
				// if drag over the rest of the table
				else {
					// drop can be done
					event.detail = detail;
				}
			}

			@Override
			public void dragOperationChanged(DropTargetEvent event) {
			}

			@Override
			public void dragLeave(DropTargetEvent event) {
			}

			@Override
			public void dragEnter(DropTargetEvent event) {
			}
		});
	}

	/**
	 * Adds file drop support.
	 */
	private void addTabFolderDropSupport() {
		Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
		int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;

		// defines files table as a drop target
		DropTarget target = new DropTarget(uiController.getUi().getFolderViewTabFolder(), operations);
		target.setTransfer(types);
		target.addDropListener(new DropTargetListener() {
			@Override
			public void dropAccept(DropTargetEvent event) {

			}

			@Override
			public void drop(DropTargetEvent event) {
				CTabFolder tabFolder = (CTabFolder) ((DropTarget) event.widget).getControl();

				CTabItem tabItem = tabFolder.getItem(tabFolder.toControl(event.x, event.y));

				if (tabItem != null) {
					FolderView folderView = (FolderView) tabItem.getData("org.o14x.alpha.ui.views.folder.FolderView");
					if (folderView != null) {
						File targetDirectory = folderView.getExplorerTab().getFolder();

						// paths of the files to be dropped
						String[] droppedPaths = (String[]) event.data;

						FileServices fileServices = uiController.getServices().getFileServices();

						// files to be dropped
						File[] droppedFiles = fileServices.toFiles(droppedPaths);

						// if there is files to be dropped
						if (droppedFiles.length > 0) {
							// move operation
							if (event.detail == DND.DROP_MOVE) {
								// if dropped files are not from the target directory
								if (!droppedFiles[0].getParentFile().equals(targetDirectory)) {
									// moves files
									fileServices.move(droppedFiles, targetDirectory, true, true);
									getUiController().getDomain().getCurrentExplorerTab().getFolderView().update();
								}
							}
							// copy operation
							else if (event.detail == DND.DROP_COPY) {
								// if dropped files are from the target directory
								if (droppedFiles[0].getParentFile().equals(targetDirectory)) {
									// modify the name of the files before copy
									fileServices.duplicate(droppedFiles, targetDirectory);
									getUiController().getDomain().getCurrentExplorerTab().getFolderView().update();
								} else {
									// copy files without modifying their names
									fileServices.copy(droppedFiles, targetDirectory, false, true);
									getUiController().getDomain().getCurrentExplorerTab().getFolderView().update();
								}
							}
						}
					}
				}
			}

			@Override
			public void dragOver(DropTargetEvent event) {
				//				CTabFolder tabFolder = (CTabFolder) ((DropTarget) event.widget).getControl();
				//
				//				CTabItem tabItem = tabFolder.getItem(tabFolder.toControl(event.x, event.y));
				//				System.out.println(tabItem);
				//				//tabFolder.setSelection(tabItem);
				//
				//				if (tabItem != null) {
				//					FolderView folderView = (FolderView) tabItem.getData("org.o14x.alpha.ui.views.folder.FolderView");
				//					if (folderView != null) {
				//						PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(folderView);
				//					}
				//				}
				//
				//				int detail = event.detail;
				//				if (event.detail == DND.DROP_NONE) {
				//					detail = DND.DROP_DEFAULT;
				//				}
			}

			@Override
			public void dragOperationChanged(DropTargetEvent event) {
			}

			@Override
			public void dragLeave(DropTargetEvent event) {
			}

			@Override
			public void dragEnter(DropTargetEvent event) {
			}
		});
	}

	/****************************************************************************************************************
	 * CONTEXT MENU
	 ***************************************************************************************************************/

	/**
	 * Adds a context menu to the table
	 */
	private void addContextMenu() {

		final MenuManager mgr = new MenuManager();
		mgr.setRemoveAllWhenShown(true);

		final FolderView folderView = this;

		mgr.addMenuListener(new IMenuListener() {

			/* (non-Javadoc)
			 * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
			 */
			public void menuAboutToShow(IMenuManager manager) {
				IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();

				boolean emptySelection = selection.isEmpty();
				//boolean multipleSelection = !emptySelection && selection.size() > 1;
				boolean singleElementSelection = !emptySelection && selection.size() == 1;
				boolean singleDirectorySelection = singleElementSelection && ((File) selection.getFirstElement()).isDirectory();

				CommandContributionItemParameter commandContributionItemParameter;
				CommandContributionItem commandContributionItem;

				commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.SystemContextMenuCommand", CommandContributionItem.STYLE_PUSH);
				commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
				mgr.add(commandContributionItem);

				mgr.add(new Separator());

				if (emptySelection) {
					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.RefreshCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.icon = ImageDescriptor.createFromImage(new Image(folderView.getSite().getShell().getDisplay(), Thread.currentThread().getContextClassLoader().getResourceAsStream("org/o14x/alpha/ui/images/refresh.gif")));
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					mgr.add(commandContributionItem);

					mgr.add(new Separator());
				}

				if (!emptySelection) {
					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.CutCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.icon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_CUT);
					commandContributionItemParameter.disabledIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED);
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					mgr.add(commandContributionItem);
				}

				if (!emptySelection) {
					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.CopyCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.icon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY);
					commandContributionItemParameter.disabledIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED);
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					mgr.add(commandContributionItem);
				}

				if (emptySelection || singleDirectorySelection) {
					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.PasteCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.icon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE);
					commandContributionItemParameter.disabledIcon = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED);
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					mgr.add(commandContributionItem);
				}

				mgr.add(new Separator());

				if (!emptySelection) {
					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.DeleteCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.icon = ImageDescriptor.createFromImage(new Image(folderView.getSite().getShell().getDisplay(), Thread.currentThread().getContextClassLoader().getResourceAsStream("org/o14x/alpha/ui/images/delete.gif")));
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					mgr.add(commandContributionItem);
				}

				if (singleElementSelection) {
					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.rename.RenameCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					mgr.add(commandContributionItem);
				}

				if (emptySelection) {

					mgr.add(new Separator());

					MenuManager newMenu = new MenuManager("New");

					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.newdirectory.NewDirectoryCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.label = "Directory";
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					newMenu.add(commandContributionItem);

					commandContributionItemParameter = new CommandContributionItemParameter(folderView.getSite(), null, "org.o14x.alpha.ui.commands.newfile.NewFileCommand", CommandContributionItem.STYLE_PUSH);
					commandContributionItemParameter.label = "File";
					commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
					newMenu.add(commandContributionItem);

					mgr.add(newMenu);
				}

			}
		});
		tableViewer.getControl().setMenu(mgr.createContextMenu(tableViewer.getControl()));
	}

	/****************************************************************************************************************
	 * GETTERS AND SETTERS
	 ***************************************************************************************************************/

	/**
	 * Returns the value of uiController.
	 *
	 * @return The value of uiController.
	 */
	public UIController getUiController() {
		return uiController;
	}

	/**
	 * Sets the value of uiController.
	 *
	 * @param uiController The value of uiController to set.
	 */
	public void setUiController(UIController uiController) {
		this.uiController = uiController;
	}

	/**
	 * Returns the value of fileTableLabelProvider.
	 *
	 * @return The value of fileTableLabelProvider.
	 */
	public FileTableLabelProvider getFileTableLabelProvider() {
		return fileTableLabelProvider;
	}

	/**
	 * Sets the value of fileTableLabelProvider.
	 *
	 * @param fileTableLabelProvider The value of fileTableLabelProvider to set.
	 */
	public void setFileTableLabelProvider(FileTableLabelProvider fileTableLabelProvider) {
		this.fileTableLabelProvider = fileTableLabelProvider;
	}

	/**
	 * Returns the value of tableViewer.
	 *
	 * @return The value of tableViewer.
	 */
	public TableViewer getTableViewer() {
		return tableViewer;
	}

	/**
	 * Sets the value of tableViewer.
	 *
	 * @param tableViewer The value of tableViewer to set.
	 */
	public void setTableViewer(TableViewer tableViewer) {
		this.tableViewer = tableViewer;
	}

	/**
	 * Returns the value of explorerTab.
	 *
	 * @return The value of explorerTab.
	 */
	public ExplorerTab getExplorerTab() {
		return explorerTab;
	}

	/**
	 * Sets the value of explorerTab.
	 *
	 * @param explorerTab The value of explorerTab to set.
	 */
	public void setExplorerTab(ExplorerTab explorerTab) {
		this.explorerTab = explorerTab;
	}
}
